/**
 * @param {number} n
 * @param {number} k
 * @return {number[][]}
 */

var combine = function (n, k) {
    let ans = []
    backTrack([], 1)
    return ans
    function backTrack(arr, p) {
        if (arr.length === k) {
            ans.push([...arr])
            return
        }
        for (let i = p; i <= n; i++) {
            arr.push(i)
            backTrack(arr, i + 1)
            arr.pop()
        }
    }
};
console.log(combine(2, 1))

